#include "StdAfx.h"
#include "WorkParam.h"

WorkParam::WorkParam(void)
{
	m_BuyData.Stage = 0;
}

WorkParam::~WorkParam(void)
{
}

void WorkParam::Clear(void)
{
    m_BuyData.WList.clear();
    m_ContInfo.CpList.clear();
	m_ContInfo.LrList.clear();
}

void WorkParam::GetZeroParam(int &sec, int &devi)
{
    sec = atoi(m_InitParam.ZeroTime.c_str());
	devi = atoi(m_InitParam.ZeroDevi.c_str());
}

void WorkParam::GetCallParam(int &sec)
{
    sec = atoi(m_InitParam.CallDelay.c_str());
}

void WorkParam::GetTareParam(float &sys, float &down, float &up)
{
	sys = (float)atof(m_InitParam.SysTare.c_str());
    down = (float)atof(m_InitParam.TareDown.c_str());
	up = (float)atof(m_InitParam.TareUp.c_str());
}

float WorkParam::GetRemainParam()
{
    return (float)atof(m_ContInfo.Today.c_str());
}

bool WorkParam::IsWeightOver(float w)
{
    float today;
	float total;

	today = (float)atof(m_ContInfo.Today.c_str());
	total = (float)atof(m_ContInfo.Total.c_str());
    total += w;

	return (total > today);
}

string WorkParam::GetUnitPrice(string &LevelId)
{
    string pr;

	for (int i = 0; i < m_InitParam.BuyInfoList.size(); i ++)
	{
        if (m_InitParam.BuyInfoList[i].Family == m_ContInfo.Family)
		{
			if (m_InitParam.BuyInfoList[i].LevelId == LevelId)
			{
				return m_InitParam.BuyInfoList[i].Price;
			}
		}
	}

	return pr;
}

int WorkParam::GetPrintParam()
{
    return atoi(m_InitParam.NumLevels.c_str());
}

int WorkParam::GetWeightListCount()
{
    return m_BuyData.WList.size();
}

bool WorkParam::IsWeightDone()
{
    bool ret = false;
    int rows;

	rows = m_BuyData.WList.size();

	for (int i = 0; i < rows; i ++)
	{
        if (m_BuyData.WList[i].Status != WS_DONE)
			goto EXIT;
	}
	ret = true;

EXIT:

	return ret;
}